<?php
	include("head.php");
	include_once("paging_function.php");
?>

<script>
function changeUrl(indexalpha)
{
var url='network.php?index='+indexalpha;
window.location=url;
}
function display()
{
	//alert('hi');
	document.edit.mode.value='display_network_costs';
	document.edit.action='display_network_costs.php';
	document.edit.submit();
}

</script>
<?php

$execCategory = mysql_query("select * from adcategories where status='Y' and langId=1");
$execCountry = mysql_query("select * from country where status='Y'");


$networksiteArr = array();
$execNetworkSites = mysql_query("select siteId from ".NETWORKSITES." where networkId='".$_REQUEST[networkId]."'");
while($fetNetworkSites = mysql_fetch_array($execNetworkSites))
{
	$networksiteArr[] = $fetNetworkSites[0];
}
/////////////////////////////////PAGING /////////////////
 	if(isset($_GET['page']) && $_GET['page']!='')
		{
		
			$page = $_GET['page'];
		}
	else
		{
			$page = 0;
		}
$limit=$adminpagelimit;
//echo $limit;
/////////////////////////////////////////////////////////////////	

// Start Save Clicks for purchase

if(isset($_POST['set_cost']))
{

mysql_query("insert into network_clicks_purchase(rowId,noOfClicks,cpc) values('main',".$_POST['ctp'].",".$_POST['cpc'].")");

}

// END Save Clicks for purchase





////////////////////////////////////////////    Block_---- DELETE  ///////////
if(isset($_POST['Submit']))
{
	$del=$_POST['del'];
	$no=count($del);
	if($no>0)
	{
	for($i=0;$i<$no;$i++)
	{
	   mysql_query("DELETE FROM ".NETWORKMASTER."  WHERE networkId= '".$del[$i]."' ");	   
	}
	echo '<script>window.location="network.php?dlt=1"</script>';
	}
	$block=$_POST['count_UPDATE'];
	if($_POST['count_UPDATE']>0)
	{
	for($no_up=0; $no_up<$block;$no_up++)
	{
	if(isset($_POST['block'.$no_up]))
	{
	 mysql_query("UPDATE ".NETWORKMASTER."  set status='N' WHERE networkId='".$_POST['block'.$no_up]."'");
	}else{
	 mysql_query("UPDATE ".NETWORKMASTER."  set status='Y' WHERE networkId='".$_POST['block_hid'.$no_up]."'");
	}
	}
	echo '<script>window.location="network.php?page='.$_GET['page'].'&loop='.$_GET['loop'].'&start='.$_GET['start'].'&blk=1"</script>';
	}
}

?>
<?php 
//////////////////////////////////////// insert edit query====================//////////
if(isset($_REQUEST['submit1']))
{ 

		if($_REQUEST['action']=='create')
		{ 
			$insert_query=mysql_query("INSERT INTO ".NETWORKMASTER." SET `networkName`='".$_POST['name']."',`networkType`= '".$_POST['type']."',`siteuserId`='0',`networkBidType`='".$_REQUEST['bidtype']."' ,`status`='".$_POST['status']."',`description`='".$_POST['description']."'"
			) or die('NETWORKMASTER '.mysql_error());


			$lastqueryid=mysql_insert_id();

			$insertdetailssql="INSERT INTO ".NETWORKDETAILS." SET `networkId`='".$lastqueryid."',`networkMinPrice`='".$_POST['networkprice']."',`costPerBidType`='".$_POST['bidcost']."'";

			$insertquerydetails=mysql_query($insertdetailssql) or die('NETWORKDETAILS '.mysql_error());

			$INSERTDETAILSSQL="INSERT INTO `".NETADDETAILS."` SET `networkId`='".$lastqueryid."'";

			$INSERTDETAILS=mysql_query($INSERTDETAILSSQL) or die('NETADDETAILS '.mysql_error());
			
			for($i=0;$i<count($_POST[icon]);$i++)
			{
	
					$insertClicks = "insert into ".NETWORKCLICKS." set networkId='".$lastqueryid."' ,noOfClicks ='".$_POST[icon][$i]."'";
					if($_POST[icon][$i]!='')
						mysql_query($insertClicks);
			}

			//$sizeofcategory = sizeof($_POST['categoryList'];

			//$val_category=$_POST['categoryList'];
			//$s = sizeof($val_category);

			for($i=0;$i<count($_POST[categoryList]);$i++)
			{			
			$query = "select adcategoryId from adcategories	where categoryName = '".$_POST[categoryList][$i]."' ";
			$res = mysql_query($query);
			$row = mysql_fetch_array($res);
			$insertSites = "insert into network_ad_category(networkId,categoryId) values('".$lastqueryid."','".$row['adcategoryId']."')";
			//echo "Query-->".$insertSites;			
			mysql_query($insertSites);
			}
//echo count($_POST[geographyList]); die();
			$str_country='';
			for($i=0;$i<count($_POST[geographyList]);$i++)
			{
			if($_POST[geographyList][$i] != 0 || $_POST[geographyList][$i] != ''){			
			$insertSites = "insert into network_country(networkId,countryId) values('".$lastqueryid."','".$_POST[geographyList][$i]."')";
			echo "Query-->".$insertSites."<br><br>";			
			mysql_query($insertSites);

			$sql_countries_iso_code_2="select countries_iso_code_2 from country where countryId = '".$_POST[geographyList][$i]."'";
			$exe_countries_iso_code_2=mysql_query($sql_countries_iso_code_2);
			$row_countries_iso_code_2=mysql_fetch_array($exe_countries_iso_code_2);

			$country_code=$row_countries_iso_code_2[0];
			
			if(count($_POST[geographyList])>1)
			{
				if($i==count($_POST[geographyList])-1)
				{
					$str_country.=$country_code;
				}
				else
				{
					$str_country.=$country_code.",";
				}
			}
			else
			{
				$str_country.=$country_code;
			}
			}
			}
			$SQL_update_network_master="update ".NETWORKMASTER." set target_countries = '".$str_country."' where networkId = '".$lastqueryid."'";
			mysql_query($SQL_update_network_master);
			
			echo '<script> window.location="network.php?inst=1"</script>';
		}

		if($_REQUEST['action']=='edit')
		{
				
			$updatesql="UPDATE `".NETWORKMASTER."` SET `networkName` = '".$_POST['name']."',`networkType` = '".$_POST['type']."',`networkBidType`='".$_REQUEST['bidtype']."',`status`='".$_POST['status']."' WHERE `".NETWORKMASTER."`.networkId='".$_REQUEST['networkId']."'";
//echo $updatesql;
			$UPDATE=mysql_query($updatesql) or die('update NETMASTER '.mysql_error());
			
			$updatesql1="UPDATE `".NETWORKDETAILS."` SET `".NETWORKDETAILS."`.`networkMinPrice`='".$_POST['networkprice']."',`".NETWORKDETAILS."`.`costPerBidType`='".$_POST['bidcost']."' WHERE  `".NETWORKDETAILS."`.networkId='".$_REQUEST['networkId']."'";
//echo $updatesql1;
			$UPDATE=mysql_query($updatesql1) or die('update NETDETAILS'.mysql_error());
	
			$updatesql2="UPDATE `".NETCOUNTRY."`SET `".NETCOUNTRY."`.`countryAbbr`='".$_POST['country']."' WHERE  `".NETCOUNTRY."`.networkId='".$_REQUEST['networkId']."'";
//echo $updatesql2;
			$UPDATE=mysql_query($updatesql2) or die('updateNETCOUNTRY '.mysql_error());			
			$execupdClicks = mysql_query("select Id from  ".NETWORKCLICKS." where networkId='".$_REQUEST[networkId]."'");
			$updClicks = array();	
			while($fgetId = mysql_fetch_array($execupdClicks))
			{
				$updClicks[] = $fgetId[Id];
			}
			
				for($j=$_POST[hidFirstId];$j<=$_POST[hidLastId];$j++)
				{
					
					if(in_array($j,$updClicks))
						
						mysql_query("update ".NETWORKCLICKS." set noOfClicks ='".$_POST[iconUpdate.$j]."' where Id='".$j."' ");
				}
				for($i=0;$i<count($_POST[icon]);$i++)
				{
// 						
				$insertClicks = "insert into ".NETWORKCLICKS." set networkId='".$_REQUEST[networkId]."' ,noOfClicks ='".$_POST[icon][$i]."'";
						if($_POST[icon][$i]!='')
							mysql_query($insertClicks);
				}
			
			$netSites= $_POST['sites'];
			if( is_array($netSites))
			{
				while (list ($key, $val) = each ($netSites)) 
				{
				
				if($val!='' && !in_array($val,$networksiteArr)){
						$insertSites = "insert into ".NETWORKSITES." set networkId='".$_REQUEST[networkId]."' , siteId ='".$val."'";
					
							mysql_query($insertSites);}
				}
			}
			$deleteSite = array_diff($networksiteArr,$netSites);
			for($cntDelsite = 0;$cntDelsite<=count($deleteSite);$cntDelsite++)
			{
				$delSites = "delete from ".NETWORKSITES." where networkId='".$_REQUEST[networkId]."' and siteId ='".$deleteSite[$cntDelsite]."'";
					
							mysql_query($delSites);
			}
			//echo '<script> window.location="network.php?updt=1"</script>';
			}
}
////////////////////////////////end////////////////////////////////////////////////////////
?>

<?php
$search="SELECT * FROM ".NETWORKMASTER ;

	if($_REQUEST['typesearch']!='' && isset($_REQUEST['typesearch']))
	{

		
		$search=$search." WHERE networkType like'".$_REQUEST['typesearch']."%'";
		
	
    	}
	if($_REQUEST['namesearch']!='' && isset($_REQUEST['namesearch']))
	{

		
		$search=$search." WHERE networkName like'".$_REQUEST['namesearch']."%'";
		
	
    	}
	if($_REQUEST['selectstatus']!='' && isset($_REQUEST['selectstatus']))
	{

		
		$search=$search." WHERE ".NETWORKMASTER.".status like'".$_REQUEST['selectstatus']."%'";
		
	
    	}
	elseif($_REQUEST['index']!='' && isset($_REQUEST['index']))
	{

		$param="index=".$_REQUEST['index'];
		$search=$search." WHERE networkName like'".$_REQUEST['index']."%'";
		
	
    	}
	
	else
	{	
	$search=$search." ORDER BY networkId  DESC";
	}
	$search=$search." limit $page,$limit";
	//echo $search;
	$searchquery=mysql_query($search) or die('error1'.mysql_error());

		$execSites = mysql_query("select adsiteId,adSiteName,adSiteUrl from adsite_master where status='Y'");

?>
<!--<fieldset>
<legend class="LEGEND">NETWORK  MANAGEMENT</legend>-->
 <table width="100%" border="0" cellspacing="0" cellpadding="3"  style="border:1px solid #666666">

 <tr><td>&nbsp;</td></tr>

 <tr><td>&nbsp;</td></tr>

 <tr><td>
 <table width="100%" border="0" cellspacing="0" cellpadding="3">
 <tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr> 
			<td height="15" colspan="2" align="center" style="color:#000000;font-size:12px;">
				<font color="#000000"><strong> NETWORK  MANAGEMENT </strong></font>
			</td> 
		</tr>

	<tr style="display:" id="editWin">
		<td colspan='2' id="ShowMsg">
		</td>
	</tr>
	<?php 
	if((isset($_GET['blk']) && $_GET['blk']==1) || (isset($_GET['dlt']) && $_GET['dlt']==1) || (isset($_GET['inst']) && $_GET['inst']==1) || (isset($_GET['updt']) && $_GET['updt']==1) )
	{
	?>
	<tr>
	
		<td colspan='2' style="color:#FF0000">
		<?php 
		if(isset($_GET['blk']) && $_GET['blk']==1)
		{
		echo $msg1="Value Blocked/Unblocked Successfully!!!";
		}
		if(isset($_GET['dlt']) && $_GET['dlt']==1)
		{
		echo $msg1="Value Deleted Successfully!!!";
		}
		if(isset($_GET['inst']) && $_GET['inst']==1)
		{
		echo $msg1="Value insert Successfully!!!";
		}
		if(isset($_GET['updt']) && $_GET['updt']==1)
		{
		echo $msg1="Value UPDATE Successfully!!!";
		}
		?></td>
	</tr>
	<?php
	}
	?>
</table>



	<table width="100%" border="0" cellspacing="0" cellpadding="3" class="tabbod">




<!-- COST -->
<?php if($_REQUEST['action'] == 'define_cost' ) { ?> 


<tr><td colspan="7" id="edit_section" style="display:;">
<fieldset>
	<legend class="LEGEND"> Define Cost for Network Ads</legend>
	<form name="edit" action="" method="POST" onSubmit="return check();" >
<input type="hidden" name="mode" id="mode" value="">
		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr>
				<td width="17%" align="left" id="admin_text">Clicks to Purchase</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="ctp" value="<?php echo $fetch['networkName'];?>" ></td>
			</tr>

			<tr>
				<td width="17%" align="left" id="admin_text">CPC</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="cpc" value="<?php echo $fetch['networkName'];?>" ></td>
			</tr>			
	
			<tr>
				<td align="center">
				<input value="<?php echo $fid; ?>" type="hidden" name="hidFirstId" id="hidFirstId">
				<input value="<?php echo $lid; ?>"  type="hidden" name="hidLastId" id="hidLastId"></td>
				<td align="center">&nbsp;</td>
				<td align="left"><input type="submit" value="Save" name="set_cost" id="set_cost" onClick="window.location='network.php'" />
				&nbsp;
				<input type="button" value="Close" name="close_frm" id="close_frm" onClick="window.location='network.php'" />

				<input type="button" value="Display" name="display_network_ads" id="display_network_ads" onClick="display()" />
				</td>
			</tr>
		</table>
	</form>
</fieldset>
</td></tr>


<? } ?>

<!-- COST -->














	<?php
	if($_REQUEST['action'] == 'create' || $_REQUEST['action'] == 'edit' || $_REQUEST['action'] == 'details')
		{
		$editsql="SELECT ".NETWORKMASTER.".networkId,".NETWORKMASTER.".networkName,".NETWORKMASTER.".networkType,".NETWORKMASTER.".networkBidType,".NETWORKMASTER.".status, ".NETWORKDETAILS.".networkMinPrice,".NETWORKDETAILS.".costPerBidType,".NETCOUNTRY.".countryAbbr FROM ".NETWORKMASTER.",".NETWORKDETAILS.",".NETCOUNTRY.",".NETADDETAILS.",".SITEMASTER." WHERE ".NETWORKMASTER.".networkId=".NETWORKDETAILS.".networkId  AND ".NETWORKMASTER.".networkId=".NETCOUNTRY.".networkId AND ".NETADDETAILS.".adsiteId=".SITEMASTER.".adsiteId AND ".NETWORKMASTER.".networkId='".$_REQUEST['networkId']."'";
//echo $editsql;
		$editquery=mysql_query($editsql);
		$fetch=mysql_fetch_array($editquery);
	?>
<tr><td colspan="7" id="edit_section" style="display:;">
<fieldset>
	<legend class="LEGEND"> <?php echo ucfirst($_REQUEST['action']);?>Network </legend>
	<form name="edit" action="" method="POST" onSubmit="return check();" >
		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr>
				<td width="17%" align="left" id="admin_text">Network Name</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="name" value="<?php echo $fetch['networkName'];?>" ></td>
			</tr>
			<tr>
				<td width="17%" align="left" id="admin_text">Network Type</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left">
					<select name="type">
						<option <?php if($fetch['networkType']=='text') echo 'selected';?> value="text">Text</option>
						<option <?php if($fetch['networkType']=='thumbnail') echo 'selected';?>  value="thumbnail">Thumbnail</option>
						<option <?php if($fetch['networkType']=='banner') echo 'selected';?>  value="banner">Banner</option>
				</select>
			</td>
			</tr>
			<tr>
				<td width="17%" align="left" id="admin_text">Network Bid Type</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><select name="bidtype" class="SMALL" >
										<option value="" selected="selected">Bid Type </option>
										<option value="CPC"  <?php if($fetch['networkBidType'] =="CPC") echo 'selected'; ?>>CPC</option>
										<option value="CPM"  <?php if($fetch['networkBidType'] =="CPM") echo 'selected'; ?>>CPM</option>
										
										</select>
				</td>
			</tr>
			<tr>
				<td width="17%" align="left" id="admin_text">Network Minimum Price</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="networkprice" value="<?php echo $fetch['networkMinPrice'];?>" ></td>
			</tr>
			<tr>
				<td width="17%" align="left" id="admin_text">Network Cost Per Bid Type</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left"><input type="text" name="bidcost" value="<?php echo $fetch['costPerBidType'];?>" ></td>
			</tr>

			<tr>
				<td width="17%" align="left" id="admin_text" valign="top">Add Clicks to Purchase</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left" valign="top">
					<?php 
						if($_REQUEST[action]=='edit')
						{
						$execClicks = mysql_query("select * from  ".NETWORKCLICKS." where networkId='".$_REQUEST[networkId]."' order by Id desc");
						$counter = 0;
						?>
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<table width="100%" border="0" cellpadding="5" cellspacing="0">
									<tbody id="files-root">
									<?php while($fetClicks = mysql_fetch_array($execClicks))
									{
										if($counter==0)
											$lid = $fetClicks[Id];
									$fid = $fetClicks[Id];
									?>
										
										<tr>
											<td align="left"><input name="iconUpdate<?php echo $fetClicks[Id];?>" class="required" type="text" value="<?php echo $fetClicks[noOfClicks] ?>"></td>
										</tr>

									<?php 
									$counter++;
									} ?>
								</tbody>
								</table>
							</td>
						</tr>
						
						<tr>
							<td><input name="TOTAL_FILE" id="TOTAL_FILE" value="1" type="hidden">
						<span onclick="addFile()" style="cursor: pointer;"><strong><font color="#6600ff">Add Another File</font></strong></span></td>
				
						</tr>
					</table>
						<?php	
						}
						else
						{	
					 ?>
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<table width="100%" border="0" cellpadding="5" cellspacing="0">
									<tbody id="files-root">
										<tr>
											<td align="left"><input name="icon[]" class="required" type="text"></td>
										</tr>
									</tbody>
								</table>
							</td>
						</tr>
						<tr>
							<td><input name="TOTAL_FILE" id="TOTAL_FILE" value="1" type="hidden">
						<span onclick="addFile()" style="cursor: pointer;"><strong><font color="#6600ff">Add Another File</font></strong></span></td>
				
						</tr>
					</table>
					<?php 
						} 
					?>
				</td>
			</tr>

			<tr>
                                    <td width="17%" align="left" valign="top">Category</td>
                                    <td width="2%" align="left">::</td>
				    <td>
				    <select multiple="multiple" id="categoryList" name="categoryList[]" size="10">
									<?php 
									while($fetchCategory = mysql_fetch_array($execCategory))
									{
									?>
										<option value="<?php echo $fetchCategory['categoryName']; ?>" ><?php echo $fetchCategory['categoryName']; ?></option>
		
									<?php
									}
									?>
									</select>
				    </td>
                                 							
		
                       </tr>

			<tr>
                                    <td width="17%" align="left" valign="top">Geography</td>
                                    <td width="2%" align="left">::</td>
				    <td>
				    <select multiple="multiple" id="geographyList" name="geographyList[]" size="10">
                                            <?php 
											while($fetchcountry = mysql_fetch_array($execCountry))
											{
											?>
				<option value="<?php echo $fetchcountry['countryId']; ?>" ><?php echo $fetchcountry['countryName']; ?></option>
															<?php
											}
											?>
                                    </select>
				    </td>
                                 							
		
                       </tr>

			<tr>
				<td width="17%" align="left" id="admin_text" valign="top">Which publishers you want to<br> add to this network?</td>
				<td width="2%" align="left">::</td>
				<td width="81%" align="left">
					<select name="sites[]" size="10" multiple>
					<?php 
					while($fetSites = mysql_fetch_array($execSites))
					{
					?>
						<option <?php if(in_array($fetSites[adsiteId],$networksiteArr)) echo 'selected';?> value="<?php echo $fetSites[adsiteId]; ?>"><?php echo $fetSites[adSiteName]; ?></option>
					<?php 
					}
					?>
					</select>
				</td>
			</tr>

			<tr>
				<td width="27%" align="left" id="admin_text">Description</td>
				<td width="10%" align="left">::</td>
				<td width="63%" align="left"> <textAREA name="description" id="description"></textAREA> </td>
			</tr> 

	
			<tr>
				<td width="27%" align="left" id="admin_text">Status</td>
				<td width="10%" align="left">::</td>
				<td width="63%" align="left">Active
				<input type="radio" name="status" <?php if($fetch['status']=='Y'){?> checked="checked" <?php } ?> value="Y" >
				&nbsp;&nbsp;Inactive
				<input type="radio" name="status" <?php if($fetch['status']=='N'){?> checked="checked" <?php } ?> value="N" >
				&nbsp;&nbsp;Pending
				<input type="radio" name="status" <?php if($fetch['status']=='P'){?> checked="checked" <?php } ?> value="P" > 
				&nbsp;&nbsp;Block
				<input type="radio" name="status" <?php if($fetch['status']=='B'){?> checked="checked" <?php } ?> value="B" >       </td>
			</tr> 
			<tr>
				<td align="center">
				<input value="<?php echo $fid; ?>" type="hidden" name="hidFirstId" id="hidFirstId">
				<input value="<?php echo $lid; ?>"  type="hidden" name="hidLastId" id="hidLastId"></td>
				<td align="center">&nbsp;</td>
				<td align="left"><?php if($_REQUEST['action']!=''){ ?><input type="submit" name="submit1" value="<?php if($_REQUEST['action']=='create'){echo INSERT;}else echo UPDATE;?>" /><?php } ?>
				&nbsp;
				<input type="button" value="Close" name="close_frm" id="close_frm" onClick="window.location='network.php'" /></td>
			</tr>
		</table>
	</form>
</fieldset>
	<?php } ?>
</td></tr>

<tr>

  <td height="15" colspan="7" align="center" style="color:#000000;font-size:12px;"><p><strong style="font-weight: 400">Click on the alphabets to browse Network name &nbsp;</strong></p><?php include_once("search_alphabets.php");?></td>

</tr>
<tr>

  <td height="15" colspan="7" align="left" style="color:#000000;font-size:12px;"><font face="Times New Roman, Times, serif" size="2"><strong>
			
		<a href="network.php?action=create"> Create Network </a></strong></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Times New Roman, Times, serif" size="2"><strong>
			
		<a href="network.php?action=define_cost">Define Cost for Network Type Ads</a></strong></font></td>
</tr>
<form name="search" method="POST" >
    <tr>
	<td colspan="6">
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td>Search By </td>
					<td valign="middle">Network Name :<input type="text" name="namesearch" value="">&nbsp;</td>					
					<td valign="middle">Network Type :<input type="text" name="typesearch" value="<?php echo $_POST['typesearch']; ?>"></td>
					<td class="SMALL"> Network Status:<select name="selectstatus" class="SMALL" >
						<option value="" selected="selected">Ad Status </option>
						<option value="Y"  <?php if($statuetype == "Y") echo 'selected'; ?>>Active</option>
						<option value="N"  <?php if($statustype == "N") echo 'selected'; ?>>Inactive</option>
						<option value="P"  <?php if($statustype == "P") echo 'selected'; ?>>Pending</option>
						<option value="B" <?php if($statustype == "B") echo 'selected'; ?>>Block</option>
					    </select>&nbsp;&nbsp;<input type="submit" name="search" value="Search">
					</td>
					<td class="SMALL"><a href="network.php" style="color:#000000;font-size:12px;">View All</a> </td>
				</tr>
				
			</table>
	</td>
    </tr>
</form>

<?php

  if(mysql_num_rows($searchquery)>0)
  	{
	
	?><form name="form_admin_management" action="" method="post">
		<tr bgcolor="#6F8DBC">
			<td width="7%" height="28" style="color:#ffffff;font-size:12px;"><strong>S.No</strong></td>
			<td width="32%" align="left" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Network Name</strong> </td>
			<td width="32%" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Network Type </strong></td>
			<td width="9%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Edit</strong></td>
			<td width="9%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Details</strong></td>
			<td width="11%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Status</strong></td>
			<td width="9%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
	</tr>
	<?php 
			$count=0;
			$sno=1;
			$loop=0;
	while($searcharray=mysql_fetch_array($searchquery))
		{
			$loop++;
			if($loop == 1)
			$bgcolor = "#F0F0FF";
			else 
			$bgcolor = "#CCCCFF";
	?>
		<tr bgcolor="<?php echo $bgcolor; ?>">
			<td height="32" style="color:#000000;font-size:12px;"><strong><?php echo $sno+$_GET['page'];//echo $searcharray['usercode']; ?></strong></td>
			<td align="left" valign="middle" style="color:#000000;font-size:12px;"><?php echo ($searcharray['networkName']); ?></td>
			<td align="left" valign="middle" style="color:#000000;font-size:12px;"><?php echo ($searcharray['networkType']); ?></td>
			<td align="center" valign="middle"><a href="network.php?action=edit&networkId=<?php echo $searcharray['networkId'];?>" ><img src="images/edit_icon.gif" border="0"/></a></td>
			<td align="center" valign="middle"><a href="network.php?action=details&networkId=<?php echo $searcharray['networkId'];?>" ><img src="images/edit_icon.gif" border="0"/></a></td>
			<td align="center" valign="middle"><strong> <?php if($searcharray['status']=='Y')
										{
											echo "Active";
										}
									if($searcharray['status']=='N')
										{
											echo "In Active";
										}
									if($searcharray['status']=='P')
										{
											echo "Pending";
										}
									if($searcharray['status']=='B')
										{
											echo "Blocked";
										}
										
										?>
				</strong></td>
			<td align="center" valign="middle"><input type="checkbox" name="del[]" value="<?php echo $searcharray['networkId'];?>"></td>
		</tr>
			<?php 
			$count++;
			$sno++;
			if($loop == 2)
				{
				$loop = 0;
				}	
		}
			?>
		<tr>
			<td colspan="3">&nbsp;</td>
			<td colspan="4" align="right"><input type="hidden" name="count_UPDATE" value="<?php echo $count; ?>">
			<input type="submit" name="Submit" value="Update"></td>
		</tr>
		<tr>
			<td colspan="7" align="center" style="color:#FF0000"><?php echo paging($search,$page,$limit,'',$param);?></td>
		</tr>
		<?php
	
	}
	
	else
	
	{
	
	?>
	<tr bgcolor="#6F8DBC">
		<td width="7%" style="color:#ffffff;font-size:12px;"><strong>S.No</strong></td>
		<td width="32%" align="center" style="color:#ffffff;font-size:12px;"><strong>Network Name</strong></td>
		<td style="color:#ffffff;font-size:12px;"><strong>Network Type </strong></td>
		<td width="9%" align="center" style="color:#ffffff;font-size:12px;"><strong>Edit</strong></td>
		<td width="9%" align="center" style="color:#ffffff;font-size:12px;"><strong>Details</strong></td>
		<td width="11%" align="center" style="color:#ffffff;font-size:12px;"><strong>Block</strong></td>
		<td align="center" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
      </tr>
    <tr>
      <td colspan="7" align="left">&nbsp;&nbsp;&nbsp;<strong><font color="#FF0000" class="DISPLAYMESSAGES">No Result Found!</font></strong></td>
    </tr>
    <?php

  	}

  ?>
</form>
  </table>
  </td>
</tr>
</table>
</td>
</tr>
</table>
<script>
var gFiles = 1;
function addFile() 
{
    var tr = document.createElement('tr');
    tr.setAttribute('id', 'file-' + gFiles);
    var td = document.createElement('td');
    td.innerHTML = '<input align="left" name="icon[]" class="required" type="text"><span onclick="removeFile(\'file-' + gFiles + '\')" style="cursor:pointer;"><strong><font color="#CC3300">Remove</font></strong></span><br>';
    tr.appendChild(td);
    document.getElementById('files-root').appendChild(tr);
	gFiles++;
  	document.getElementById('TOTAL_FILE').value=gFiles;
}
function removeFile(aId) 
{
    var obj = document.getElementById(aId);
    obj.parentNode.removeChild(obj);
}
</script>
<?php 

include("foot.php");?>